/**
 * Copyright (C) 2015-2016  Shuishun Zhou  All Rights Reserved.
 * File name:       dll_demo_com_dll_api.c
 * Version:         0.0.1
 * Description:     study dll used demo file for com_dll_api test
 * Function List:
 * History:
 * No.          Date        Author          Note
 * 01       2015-02-23  Water (sszhouplus@qq.com) Create
 **/
#include <stdio.h>
#include "hello_dll.h"
#include "com_dll_api.h"


void main(int argc, char **argv)
{
	void *dll_module;
	char *p_err_str;

	if (argc < 2) {
		printf("cmd fmt: <dll path>\n");
		return;
	}

	printf("start load library\n");
	dll_module = dll_open(argv[1]);

	if (dll_module) {
		printf("get function entry from dll by symbol name\n");
		hello_dll = dll_get_symbol(dll_module, "hello_dll");

		if (hello_dll) {
			hello_dll();
		} else {
			p_err_str = dll_last_error();
			printf("can't get valid function entry,"
				"error code: %s\n", p_err_str);
		}

		dll_close(dll_module);
	} else {
		p_err_str = dll_last_error();
		printf("load library fail, error code: %s\n", p_err_str);
	}

	printf("\n__end__\n");
}